Skip to content

dsh-huggingface: the Hub as a surface over the machine's own hf CLI and cache - #18

Merged
vecnode merged 1 commit into
mainfrom
feat/dsh-huggingface
Nov 28, 2026
Merged

vecnode merged 1 commit into
mainfrom
feat/dsh-huggingface

Conversation

@vecnode

@vecnode vecnode commented Nov 28, 2026

Copy link
Copy Markdown
Owner

What this adds

dsh-huggingface — a host-only bundle with five tools and two skills over
the machine's own hf CLI (huggingface_hub 1.26.1 here) and the cache on disk.
It answers the question a person asks before committing disk and bandwidth:
what does this repo weigh, and do I already have it?

Tool Answers
hf_status the cache root through the library's own precedence, every repo with byte-exact sizes, and the split between complete repos and metadata-only stubs; auth as a presence only
hf_repo licence, gated flag, architecture, weight with its measure named, the files each consumer would fetch, and the local verdict (complete / stub / stale / absent)
hf_cache list with no CLI at all, plus verify / prune / rm — an unconfirmed removal is the CLI's own --dry-run, rm needs the repo id repeated back
hf_download the only bytes-moving call: a byte ceiling, then confirm, then the bytes the cache actually gained
hf_search ranked ids with the flags a download needs

Skills: huggingface-hub (the v1 hf command set, revisions, gated repos,
hf://, the JSON contract, the raw API) and huggingface-cache (the
blobs/snapshots/refs layout, cached-vs-complete, verify/prune/rm, moving the
cache, the Windows link-vs-copy trap).

Three measured findings shaped the design

  1. The CLI's JSON is not arithmetic. hf cache ls --json answers
    "size": "17.9G" and "last_accessed": "3 months ago". Byte-exact numbers
    therefore come from walking the directory tree, not from parsing a screen.
  2. Blobs are hash-named, and both sides hold the same bytes. An extension
    test against blobs/9f3c… calls every canonical POSIX repo weightless, and
    summing blobs and snapshots doubles a cache. Weights are detected from
    snapshot names, and exactly one side is summed — the snapshot side on a
    machine where Xet wrote copies and blobs/ is empty.
  3. This CLI line has no per-file sizes. --expand siblings carries
    rfilename only and there is no --blobs flag, so the repo weight is
    used_storage, labelled as such; a narrowed selection says it is unmeasured
    instead of inventing a number.

On the machine that wrote this: 49 repos / 19.8 GB cached, 42 of them
metadata only
— a fact no directory listing shows and the reason the row earns
its place.

Verification

packages/dsh-huggingface: node checks/check-huggingface-node.mjs   217 checks, 0 failed
scripts/checks/check-node-routes.mjs                               all node-route checks passed
scripts/checks/check-no-secrets.mjs                                OK
scripts/checks/check-scripts.mjs                                   OK

The package check needs no network and touches no real cache: the cache is a
fixture tree in a temp dir (including the double-count and no-blobs layouts), and
the CLI is a fake runner that records the exact argv — which is how the -y /
--dry-run decisions and the "no download over the ceiling" rule are asserted
rather than hoped for. A download in the check writes real bytes, so addedBytes
is measured. Live verification against the real CLI is in the package README.

Also: the root README/ARCHITECTURE rows, the .dsh-version.json entry, and the
banner (35 plugins, 59 skills. — the counts moved by this bundle, 33 → 35 and
51 → 59 counting dsh-comfyui's six skills that merged after the last banner).

Not in this PR

Image generation, uploading, repo creation/deletion, reading or accepting a
token, and running the CLI's own updater.

…nd cache

A new host-only bundle, five tools and two skills, that answers the question a
person asks before committing disk and bandwidth: what does this repo weigh, and
do I already have it?

- hf_status: the cache root through the library's own precedence, every repo with
  byte-exact sizes, and the split between complete repos and metadata-only stubs.
  Auth is reported as a presence; the token is never read, echoed or accepted.
- hf_repo: licence, gated flag, architecture, weight with its measure named, the
  files each consumer would fetch, and the local verdict (complete / stub / stale
  / absent).
- hf_cache: list without any CLI, plus verify / prune / rm - an unconfirmed
  removal is the CLI's own --dry-run, rm needs the repo id repeated back.
- hf_download: the only bytes-moving call; a byte ceiling, then `confirm`, then
  the bytes the cache actually GAINED.
- hf_search: ranked ids with the flags a download needs.

Three measured facts shaped the design: the CLI's JSON reports "17.9G" and
"3 months ago" rather than bytes and timestamps, so sizes come from the tree;
blobs are hash-named, so weights are detected from snapshot names and only ONE
side of the layout is summed; and this CLI line has no per-file sizes, so the
repo weight is used_storage and a narrowed selection says it is unmeasured
instead of inventing a number.

On the machine that wrote this: 49 repos / 19.8 GB cached, 42 of them metadata
only, and hf 1.26.1.

Checks: node checks/check-huggingface-node.mjs (217), check-node-routes,
check-no-secrets, check-scripts - all pass.
@vecnode
vecnode merged commit ed45dc9 into main Nov 28, 2026
1 check passed
@vecnode
vecnode deleted the feat/dsh-huggingface branch November 28, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant